<template>
  <div>
    <div class="zhuanti">
      <div class="topicBox" v-for="item in dataArr" :key="item.id">
        <img v-lazy="item.scene_pic_url" alt="" />
        <div class="title">{{ item.title }}</div>
        <p class="op">{{ item.subtitle }}</p>
        <section>{{ "￥ " + item.price_info.toFixed(2) + "元 起" }}</section>
      </div>

      <van-pagination
        v-model="page"
        :page-count="totalPages"
        mode="simple"
        @change="pageChange"
      />

      <div class="empty"> 

      </div>
    </div>
  </div>
</template>

<script>
import { GetTopicData } from "@/request/api";
export default {
  data() {
    return {
      page: 1, //当前页数
      size: 10, //每页显示的个数
      dataArr: [], //专题的数组
      pageSize: 10, //每页个数
      currentPage: 1, //当前页
      totalPages: 0, // 总页数
      count: 0, //总专题数
    };
  },
  created() {
    this.TopicPageChange(); //调用专题数据封装的函数
  },
  methods: {
    TopicPageChange() {
      //把专题的数据请求封装成函数,方便调用
      GetTopicData({
        page: this.page,
        size: this.size,
      }).then((res) => {
        if (res.errno == 0) {
          this.dataArr = res.data.data;
          this.count = res.data.count;
          this.currentPage = res.data.currentPage;
          this.totalPages = res.data.totalPages;
          this.pageSize = res.data.pageSize;
        }
      });
    },
    pageChange() {
      this.currentPage = this.page; //点击下一页或上一页,让当前页等于 当前页数
      this.TopicPageChange();
      scrollTo(0, 0);
    },
  },
};
</script>
 
<style lang = "less" >
.zhuanti {
  background-color: #eee;
  font-family: "黑体";
  text-align: center;
  margin-bottom: 70px;
  .topicBox {
    padding-bottom: 20px;
    margin-bottom: 20px;
    background-color: #fff;
  }
  img {
    width: 100%;
    height: 100%;
  }

  .title {
   padding-top: 10px;
  padding-bottom: 20px;
  font-size: 18px;
  }
  .op{
    font-size: 16px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  }
  section {
    font-size: 14px;
  padding:20px 0;
  color: darkred;
  }
  .van-pagination__page-desc {
    display: none;
  }
  .van-pagination__item {
    color: darkred;
  }
  .empty{
    height: 100px;
  }
}
</style>